function enableButton(id) {
	document.getElementById(id).disabled = false;
}

function launchApplication(application) {
	var environment = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);

	var root = environment.get("SYSTEMROOT");

    try {            
        var ua = navigator.userAgent.toLowerCase();
        if (ua.indexOf("msie") != -1) {
            MyObject = new ActiveXObject("WScript.Shell")
            MyObject.Run(application);
        } else {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

            var exe = window.Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
            exe.initWithPath(root + "\\" + application);
            var run = window.Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess);
            run.init(exe);
            var parameters = [""];
            run.run(false, parameters, parameters.length);
        }
    } catch (ex) {
        alert(ex.toString());
    }
}

function validateSignUp() {
	var valid = "<img src=\"images/ok.png\">";
	var invalid = "<img src=\"images/nok.png\">";
	
	username = document.getElementById("username").value;
	dynamicDiv("username_hint", "common/user/email_check.php?method=register&email=" + username);

	password = document.getElementById("password").value;
	confirm_password = document.getElementById("confirm_password").value;
	
	if (confirm_password != "") {
	if (confirm_password == password) {
		document.getElementById("password_hint").innerHTML = valid;
	}
	else {
		document.getElementById("password_hint").innerHTML = invalid;
	}
	}
}

function clearForm(form) {
	var formElements = form.elements;
	for (i = 0; i < formElements.length; i++) {
	    field_type = formElements[i].type.toLowerCase();
	    switch (field_type) {
	        case "text":
	        case "password":
	        case "textarea":
	        case "hidden":
	    	    formElements[i].value = "";
	            break;
	        case "radio":
	        case "checkbox":
	            if (formElements[i].checked) {
	        	    formElements[i].checked = false;
	            }
	            break;
	        case "select-one":
	        case "select-multi":
	    	    formElements[i].selectedIndex = -1;
	            break;
	        default:
	            break;
	    }
	}
	if (formElements.length > 0) {
		formElements[0].focus();
	}
	$.uniform.update("input, button, select");
}

function hostSelection() {
	
	var installationButton =  document.getElementsByName("Installation");
	
	var hostSelection =  document.getElementsByName("hostSelection[]");
	
	for (var i = 0; i < hostSelection.length; i++) {
	    if (hostSelection[i].checked) {
		    installationButton[0].disabled = false;
		    $.uniform.update("input, button, select");
			return;
		}
	}
	installationButton[0].disabled = "disabled";
	$.uniform.update("input, button, select");
}

function checkBuildInstallation() {
	var msg = "You are about to install\n\r";
	
    var naSelection =  document.getElementsByName("naBuild");
	na_build = naSelection[0].options[naSelection[0].selectedIndex].value;
	
	var sartSelection =  document.getElementsByName("sartBuild");
	sart_build = sartSelection[0].options[sartSelection[0].selectedIndex].value;
	
	var cmsSelection =  document.getElementsByName("cmsBuild");
	cms_build = cmsSelection[0].options[cmsSelection[0].selectedIndex].value;
	
	var hosts = "";
	var hostSelection =  document.getElementsByName("hostSelection[]");
	for (i = 0; i < hostSelection.length; i++) {
	    if (hostSelection[i].checked) {
		    hosts += hostSelection[i].value + "\n\r";
		}
    }

		
	msg = msg + "NA:   " + na_build + "\n\r";
	msg = msg + "SART: " + sart_build + "\n\r";
	msg = msg + "CMS : " + cms_build + "\n\r";
	msg = msg + "on hosts: " + hosts;
	if (confirm(msg)) {
	    document.forms["hostForm"].submit();
	    return true;
	}
	else {
		return false;
	}
}